package com.dongge.action;

import com.dongge.vo.UserVO;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * Created by Administrator on 2015/9/12.
 */
@Controller
@Scope("prototype")
public class LoginAction extends ActionSupport implements SessionAware,ModelDriven<UserVO> {
    private UserVO userVO = null;
    private Map<String,Object> session = null;
    public UserVO getModel() {
        userVO = new UserVO();
        return userVO;
    }

    public void setSession(Map<String, Object> session) {
        this.session = session;
    }

    @Override
    public String execute() throws Exception {
        if("admin".equals(userVO.getUsername())&&"123456".equals(userVO.getPassword())){
            session.put("user","dongge");
            return  SUCCESS;
        }
        return LOGIN;
    }
}
